package util;
import java.util.Iterator;

import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import jieba.JiebaSegmenter;
/**
* @author 听风寂  ，林舒馨
* @date 2020/1/8
* @ClassName Partword
*/
public class Partword {
	public static List<String> part(String keytext){
		JiebaSegmenter segmenter = new JiebaSegmenter();
        List<String> wordList=segmenter.sentenceProcess(keytext);
        Iterator it = wordList.iterator();
        while(it.hasNext()) {
        	String str = (String) it.next();
        	if(judgeMarks(str)){
        		it.remove();
        	}
        		
        }
		return wordList;
        
	}
	static Pattern patPunc = Pattern.compile("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~！@#￥……&*（）——|{}【】‘；：”“'。，、？]$");
	static boolean judgeMarks(String str) {
		
        Matcher matcher = patPunc.matcher(str);
        return  matcher.find(); 
	}
}
